package com.sansi.pencilbook.mapper;

import com.sansi.pencilbook.entity.Admin;
import org.apache.ibatis.annotations.Insert;
import org.apache.ibatis.annotations.Mapper;
import org.apache.ibatis.annotations.Select;
import org.apache.ibatis.annotations.Update;

import java.sql.SQLException;
import java.util.List;

/**
 * 功能说明: 管理员的增删改查
 *
 * @author lsy13
 */
@Mapper
public interface AdminMapper {

    @Select("select admin_id, admin_account, admin_password from admin")
    public List<Admin> findAll() throws SQLException;

    @Select("select admin_id, admin_account, admin_password from admin " +
            "where admin_account=#{account}")
    public Admin findAdminByAccount(String account) throws SQLException;

    @Insert("insert into admin (admin_id, admin_account, admin_password) " +
            "values (#{adminId}, #{adminAccount}, #{adminPassword})")
    public int saveAdmin(Admin admin) throws SQLException;

    @Update("update admin set admin_password=#{adminPassword} " +
            "where admin_account=#{adminAccount}")
    public int updateAdmin(Admin admin) throws SQLException;
}
